﻿@{
    ViewData["Title"] = "Index";
}

@model PageListParams<Sikiro.Web.Admin.Models.Role.RoleParams>
@section Head{
    <link rel="stylesheet" href="~/layuiadmin/style/admin.css" media="all">
}

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">

                <layuiInput asp-for="Params.RoleName" text="角色名称" placeholder="请输入" />

                <layuiTableFreshButton id="btn-submit" targetFormId="Role-table" />
            </div>
        </div>

        <div class="layui-card-body" id="Role">
            <div style="padding-bottom: 10px;">
                <LayuiButton id="btn-add" class="layui-btn layuiadmin-btn-admin" data-type="add" PermCode="@PermCode.Role_Add.GetHashCode()">添加</LayuiButton>
            </div>

            <layuiTable id="Role-table" lay-filter="Role-table" toolbar="admin-toolBar" toolbarweight="230" colsModel="typeof(RoleVo)" asp-action="List" asp-controller="Role" PermCode="@PermCode.Role_List.GetHashCode()" />

            <script type="text/html" id="admin-toolBar">
                <LayuiButton class="layui-btn layui-btn-xs layui-btn-mini" lay-event="edit" PermCode="@PermCode.Role_Edit.GetHashCode()">编辑</LayuiButton>
                <LayuiButton class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" PermCode="@PermCode.Role_Delete.GetHashCode()">删除</LayuiButton>
                <LayuiButton class="layui-btn layui-btn-xs layui-btn-mini" lay-event="jurisdiction" PermCode="@PermCode.Role_Jurisdiction.GetHashCode()">权限设置</LayuiButton>
            </script>
        </div>
    </div>
</div>


@section Scripts
    {
    <script>
        $(function () {

            var del = function (id) {
                $.Delete("/Role/Delete", { id: id }, function () {
                    $("#btn-submit").click();
                });
            }

            var edit = function (id) {
                $.openLayer("编辑角色", "/Role/Edit?id=" + id, function () {
                    $("#btn-submit").click();
                }, 480, 380);
            }

            var jurisdiction = function (id) {
                $.openLayer("权限设置", "/Role/jurisdiction?id=" + id, function () {
                    $("#btn-submit").click();
                }, 480, 680);
            }

            table.on('tool(Role-table)',
                function (obj) {

                    var id = obj.data.id;

                    if (obj.event === 'edit') {
                        edit(id);
                    }
                    else if (obj.event === 'del') {
                        del (id);
                    }
                    else if (obj.event === 'jurisdiction') {
                        jurisdiction(id);
                    }
                });

            $('#Role #btn-add').on("click", function () {
                $.openLayer("添加角色", "/Role/Add", function () {
                    $("#btn-submit").click();
                }, 480, 380);
            });
        });
    </script>
}
